package loop;

/**
 * @author:WIN10
 * @date:2022/1/15
 * @describe:堆、栈、常量池 对于String
 * ==比较的是两个地址是否相同，equals()判断是两个值是否相等
 */
public class HeapStackPool {

    public static void main(String[] args) {
        //存放在常量池中(常量池在堆里)
        String one = "abc";
        String two = "abc";
        String three = new String("abc");

        if (one.equals(two)) {
            System.out.println(">>>: 值相同");
        }
        if (one == two) {
            System.out.println(">>>: 地址相同");
        }
        if (two == three) {
            System.out.println(">>>:  地址相同");
        } else {
            System.out.println(">>>: 地址不相同");
        }
        if (two.equals(three)) {
            System.out.println(">>>：值相同");
        } else {
            System.out.println(">>>：值不相同");
        }
    }
}
